<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="../templates/hub.xhtml">
	<ui:define name="titre">#{lbl['rail.title']}</ui:define>
	<ui:define name="hub_page">

		<!-- Inclusion du bloc de navigation simple. -->
		<ui:include src="../blocs/inc_navigation_empty.xhtml" />

		<!-- La liste des voies. -->
		<h:form id="rails_form">
			<h:panelGrid id="rails_panel_container" width="100%">

				<!-- Le panneau des messages (pour info uniquement). -->
				<rich:messages rendered="#{railManaged.displayMessage}" />

				<rich:dataTable value="#{railManaged.lstRails}" var="rail"
					rowClasses="rich_datagrid_even_line, rich_datagrid_odd_line"
					iterationStatusVar="it" id="rails_table" styleClass="stable"
					rows="15">

					<f:facet name="noData">
						<h:outputText value="#{msg['msg.info.nodata']}" />
					</f:facet>

					<rich:column style="width:6%;text-align:left">

						<!-- Fonction pour assurer le filtrage sur le type de faisceau -->
						<a4j:jsFunction name="doTypeBundleFilter"
							action="#{railManaged.filterTypeBundle}" render="rails_table">
							<a4j:param name="typeBundleId"
								assignTo="#{railManaged.typeBundleId}" />
						</a4j:jsFunction>

						<f:facet name="header">
							<h:panelGroup>
								<h:outputText value="#{lbl['rail.bundle']}" />
								<br />
								<!-- Menu déroulant pour la liste des types de faisceaux. -->
								<h:selectOneMenu id="typeBundleId"
									value="#{railManaged.typeBundleId}"
									onchange="doTypeBundleFilter(this.value);">
									<f:selectItem itemValue="0"
										itemLabel="#{lbl['select.bundle.default']}" />
									<f:selectItems value="#{repositoryManaged.lstTypeBundles}" />
								</h:selectOneMenu>
							</h:panelGroup>
						</f:facet>
						<h:outputText value="#{rail.typeBundle.label}" />
					</rich:column>

					<rich:column style="width:4%;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['rail.number']}" />
						</f:facet>
						<h:outputText value="#{rail.number}" />
					</rich:column>

					<rich:column style="width:4%;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['rail.util.length']}" />
						</f:facet>
						<h:outputText value="#{rail.utilLength}" />
					</rich:column>

					<rich:column style="width:8%">
						<f:facet name="header">
							<h:outputText value="#{lbl['rail.electrical']}" />
						</f:facet>
						<h:outputText value="#{rail.electrical}" />
					</rich:column>

					<rich:column style="width:6%">
						<f:facet name="header">
							<h:outputText value="#{lbl['rail.destination']}" />
						</f:facet>
						<h:outputText value="#{rail.destinationLabel}" />
						<h:outputText value="#{rail.label}" />
					</rich:column>

					<rich:column style="width:40%">
						<f:facet name="header">
							<h:outputText value="#{lbl['rail.assignment']}" />
						</f:facet>
						<h:outputText value="#{rail.assignment}" />
					</rich:column>

					<rich:column>
						<f:facet name="header">
							<h:outputText value="#{lbl['common.comment']}" />
						</f:facet>
						<h:outputText value="#{rail.comment}" />
					</rich:column>

					<rich:column style="width:3%;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.update']}" />
						</f:facet>
						<a4j:commandLink execute="@this" render="edit_panel"
							oncomplete="#{rich:component('edit_popup')}.show()">
							<h:graphicImage value="../../imgs/icons/ico_update.png"
								width="20" />
							<a4j:param value="#{it.index}"
								assignTo="#{railManaged.currentRailIndex}" />
							<f:setPropertyActionListener target="#{railManaged.currentRail}"
								value="#{rail}" />
						</a4j:commandLink>
					</rich:column>

					<rich:column style="width:3%;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['rail.active']}" />
						</f:facet>
						<h:graphicImage value="../../imgs/icons/ico_info_20x20.png"
							rendered="#{rail.active}" />
						<h:graphicImage value="../../imgs/icons/ico_error_20x20.png"
							rendered="#{!rail.active}" />
					</rich:column>

					<f:facet name="footer">
						<rich:dataScroller page="#{railManaged.page}" />
					</f:facet>
				</rich:dataTable>
			</h:panelGrid>

			<!-- Pilotage des lignes tableau. -->
			<ui:include src="../blocs/inc_selector.xhtml" />

			<!-- ******************************** -->
			<!-- Les panneaux de contrôle (CRUD). -->
			<!-- ******************************** -->

			<rich:popupPanel header="#{lbl['rail.edit']}" id="edit_popup"
				domElementAttachment="parent" autosized="true"
				onbeforeshow="centerPopup(435,300,'rails_form:edit_popup');"
				onshow="makeFocusOnField('rails_form:label');"
				headerClass="rich_panel_popup_head">
				<h:panelGrid columns="1" styleClass="panel_saisie">
					<h:panelGrid columns="2" id="edit_panel"
						columnClasses="_left_top, _left">

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.type.bundle']}" /> : 
						</h:panelGroup>
						<h:outputText value="#{railManaged.currentRail.typeBundle.label}"
							style="font-weight:bold" />

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.number']}" /> : 
						</h:panelGroup>
						<h:outputText value="#{railManaged.currentRail.number}"
							style="font-weight:bold" />

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.active']}" /> : 
						</h:panelGroup>
						<h:selectOneMenu id="active"
							value="#{railManaged.currentRail.active}">
							<f:selectItem itemLabel="#{lbl['common.no']}" itemValue="false" />
							<f:selectItem itemLabel="#{lbl['common.yes']}" itemValue="true" />
						</h:selectOneMenu>

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.available']}" /> : 
						</h:panelGroup>
						<h:selectOneMenu id="available"
							value="#{railManaged.currentRail.available}">
							<f:selectItem itemLabel="#{lbl['common.yes']}" itemValue="true" />
							<f:selectItem itemLabel="#{lbl['common.no']}" itemValue="false" />
						</h:selectOneMenu>

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.destination.only']}" /> : 
						</h:panelGroup>
						<h:selectOneMenu id="destinationId"
							value="#{railManaged.currentRail.destinationId}">
							<f:selectItems value="#{repositoryManaged.lstDestinations}" />
						</h:selectOneMenu>

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.label']}" /> : 
						</h:panelGroup>
						<h:inputText id="label" value="#{railManaged.currentRail.label}" />

						<h:panelGroup>
							<h:outputText value="#{lbl['rail.assignment']}" /> : 
						</h:panelGroup>
						<h:inputTextarea id="assignment"
							value="#{railManaged.currentRail.assignment}" cols="60" rows="10" />

						<h:panelGroup>
							<h:outputText value="#{lbl['common.comment']}" /> : 
						</h:panelGroup>
						<h:inputTextarea id="comment"
							value="#{railManaged.currentRail.comment}" cols="60" rows="10" />
					</h:panelGrid>

					<h:panelGrid columns="2" columnClasses="_left, _right" width="100%">
						<a4j:commandButton value="#{lbl['common.button.cancel']}"
							id="rail_b_cancel_edit"
							onclick="#{rich:component('edit_popup')}.hide(); return false;" />

						<a4j:commandButton value="#{lbl['common.button.validate']}"
							render="rails_panel_container" execute="edit_panel"
							id="rail_b_edit" action="#{railManaged.edit}"
							oncomplete="if ('#{railManaged.maximumSeverity}'=='INFO'){#{rich:component('edit_popup')}.hide();}" />
					</h:panelGrid>
				</h:panelGrid>
			</rich:popupPanel>
		</h:form>
	</ui:define>
</ui:composition>
</html>